<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<div>
	<br/><br/><br/><br/><br/>
	<br/><br/>
	<form name="setPass" action="" method="post">
    	<table>
    		<tr align="center">
    			<td colspan="3">设置密码</td>
    		</tr>
    		<tr align="center">
    			<td colspan="3"></td>
    		</tr>
    		<tr>
    			<td align="right">密码：</td>
    			<td align="left"><input type="password" id="userpass" name="userpass" /></td>
    			<td align="left"><span id="first"></span></td>
    		</tr>
    		<tr>
    			<td align="right">确认密码：</td>
    			<td align="left"><input type="password" id="repass" name="repass"/></td>
    			<td align="left"><span id="second"></span></td>
    		</tr>
    		<tr align="center">
    			<td colspan="3"></td>
    		</tr>
    		<tr align="center">
    			<td colspan="3">
	    			<input type="reset" value="重置" />
	    			<input type="button" name="save" value="保存"/>
    			</td>
    		</tr>
    	</table>
    </form>
    <script type="text/javascript">
	    $(document).ready(function(){
	    	$("#repass").blur(function(){
	    		var pass = $("#userpass").val();
	    		var spass = $("#repass").val();
	    		if(spass != pass){
	    			alert("两次密码不一致，请重新输入！");
	    		}
		    });
		    
		    $("input[name='save']").click(function(){
		    	var pass = $("#userpass").val();
	    		var spass = $("#repass").val();
	    		if(pass == ""){
	    			alert("请输入密码！");
	    			return false;
	    		}
	    		if(spass == ""){
	    			alert("请输入确认密码！");
	    			return false;
	    		}
	    		if(spass != pass){
	    			alert("两次密码不一致，请重新输入！");
	    			return false;
	    		}
	    		$.ajax({
	    		   type: "POST",
				   url: "../doctor/save-password.html",
				   data: {doctorId:"${loginDoctor.id}",userpass:pass},
				   dataType: "json",
				   success: function(msg){
				     alert( msg );
				     document.setPass.save.disabled = true;
				   }
	    		});
		    });
	    });
    </script>
</div>